using System;
using System.Net;

namespace Salient.Web.Hosting
{
    ///<summary>
    ///</summary>
    public interface IWebServer : IDisposable
    {
        /// <summary>
        /// The root URL of the running web application
        /// </summary>
        string RootUrl { get; }

        /// <summary>
        /// Combine the RootUrl of the running web application with the relative url specified.
        /// </summary>
        /// <param name="relativeUrl"></param>
        /// <returns></returns>
        string NormalizeUrl(string relativeUrl);

        /// <summary>
        /// Will start specified application as "localhost" on loopback and first available port in the range 8000-10000 with vpath "/"
        /// </summary>
        /// <param name="applicationPath">Physical path to application.</param>
        void StartServer(string applicationPath);

        /// <summary>
        /// Will start specified application on loopback
        /// </summary>
        /// <param name="applicationPath">Physical path to application.</param>
        /// <param name="port">Port to listen on.</param>
        /// <param name="virtualPath">Optional. defaults to "/"</param>
        /// <param name="hostName">Optional. Is used to construct RootUrl. Defaults to "localhost"</param>
        void StartServer(string applicationPath, int port, string virtualPath, string hostName);


        /// <summary>
        /// </summary>
        /// <param name="applicationPath">Physical path to application.</param>
        /// <param name="ipAddress">IP to listen on.</param>
        /// <param name="port">Port to listen on.</param>
        /// <param name="virtualPath">Optional. default value '/'</param>
        /// <param name="hostName">Optional. Used to construct RootUrl. Defaults to 'localhost'</param>
        void StartServer(string applicationPath, IPAddress ipAddress, int port, string virtualPath,string hostName);

        /// <summary>
        /// <para>Stops the server.</para>
        /// </summary>
        void StopServer();

    }
}